//
//  HttpRequest.h
//  AFNetworkingDemo
//  http://www.tuicool.com/articles/mUVBf2e
//  AFNetworking 再封装
//  Created by mobao on 16/4/15.
//  Copyright © 2016年 mobao. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>
#import <SVProgressHUD.h>


 //网络请求类型
typedef NS_ENUM(NSUInteger,HttpRequestType) {
    /**
     *  get请求
     */
    HttpRequestTypeGet = 0,
    /**
     *  post请求
     */
    HttpRequestTypePost
};


@interface HttpRequest : AFHTTPSessionManager

+(instancetype)sharedClient;

/*!
 *  @author wxx, 16-04-18 11:04:14
 *
 *  get请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    成功的结果
 *  @param failure    失败的结果
 *  @param showHud    是否展示指示器
 *
 *  @return NSURLSessionDataTask
 */
-(NSURLSessionDataTask*)getWithURLString:(NSString*)URLString
                              parameters:(id)parameters
                                 showHUD:(BOOL)showHud
                                 success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                                 failure:(void(^)(NSURLSessionDataTask *task, NSError *error))failure;


-(NSURLSessionDataTask*)postWithURLString:(NSString *)URLString
                               parameters:(id)parameters
                                  showHUD:(BOOL)showHud
                                  success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                                  failure:(void (^)(NSURLSessionDataTask * task, NSError *error))failure;

-(NSURLSessionDataTask*)getWithURLString:(NSString*)URLString
                              parameters:(id)parameters
                                 success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                                 failure:(void(^)(NSURLSessionDataTask *task, NSError *error))failure;

-(NSURLSessionDataTask*)postWithURLString:(NSString *)URLString
                               parameters:(id)parameters
                                  success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                                  failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;

/*!
 *  @author wxx, 16-04-18 14:04:18
 *
 *  通过请求类型确定请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param type       请求类型
 *  @param showHud    是否展示指示器
 *  @param success    请求成功
 *  @param failure    请求失败
 *
 *  @return NSURLSessionDataTask
 */
-(NSURLSessionDataTask*)requestWithURLString:(NSString *)URLString
                                  parameters:(id)parameters
                                        type:(HttpRequestType)type
                                     showHUD:(BOOL)showHud
                                     success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                                     failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;


@end
